package com.gxa.modules.communityManagement.service.impl;
import com.gxa.modules.communityManagement.entity.HouseRent;
import com.gxa.modules.communityManagement.entity.RentAppliances;
import com.gxa.modules.communityManagement.form.HouseRentForm;
import com.gxa.modules.communityManagement.mapper.HouseRentMapper;
import com.gxa.modules.communityManagement.service.HouseRentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class HouseRentServiceImpl implements HouseRentService {
    @Autowired
    private HouseRentMapper houseRentMapper;

    @Override
    public List<HouseRent> queryAll(HouseRent houseRent) {
        List<HouseRent> houseRents=this.houseRentMapper.queryAll(houseRent);
        return houseRents;
    }

    @Override
    public void updateStatus(HouseRentForm houseRentForm) {
        this.houseRentMapper.updateStatus(houseRentForm);
    }

    @Override
    public void add(HouseRent houseRent) {
        this.houseRentMapper.add(houseRent);
        for (int i=0;i<houseRent.getAppliancesList().size();i++){
             RentAppliances rentAppliances=new RentAppliances(houseRent.getId(),houseRent.getAppliancesList().get(i).getId());
        this.houseRentMapper.addRelation(rentAppliances);
        }

    }

}
